{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block title %}注册 - {{ parent() }}{% endblock %}
{% set script_controller = 'auth/register' %}

{% block content %}

<div class="es-section login-section">
  <div class="logon-tab clearfix">
    <a href="{{ path('login', {goto:_target_path}) }}">登录帐号</a>
    <a class="active">注册帐号</a>
  </div>
  <div class="login-main">
    {% if isRegisterEnabled %}
      <form id="register-form" method="post" action="">
        {{ web_macro.flash_messages() }}
      
        {% if setting('auth.register_mode') == 'email' %}
          <div class="form-group mbl">
            <label class="control-label required" for="register_email">邮箱地址</label>
            <div class="controls">
              <input type="text" id="register_email" name="email" required="required" class="form-control input-lg" data-url="{{path('register_email_check')}}" placeholder="填写你常用的邮箱作为登录帐号">
              <p class="help-block"></p>
            </div>
          </div>
        {% elseif setting('auth.register_mode') == 'mobile' %}
          <div class="form-group mbl">
            <label class="control-label required" for="register_mobile">手机号码</label>
            <div class="controls">
              <input type="text" id="register_mobile" name="verifiedMobile" required="required" class="form-control input-lg" data-url="{{path('register_mobile_check')}}" placeholder="填写你常用的手机号码作为登录帐号">
              <p class="help-block"></p>
            </div>
          </div>
        {% else %}
          <div class="form-group mbl">
            <label class="control-label required" for="register_emailOrmobile">手机/邮箱</label>
            <div class="controls">
              <input type="text" id="register_emailOrMobile" name="emailOrMobile" required="required" class="form-control input-lg" data-url="{{path('register_email_or_mobile_check')}}" placeholder="填写你常用的邮箱或手机号码作为登录帐号">
              <p class="help-block"></p>
            </div>
          </div>
        {% endif %}

        <div class="form-group mbl">
          <label class="control-label required" for="register_nickname">用户名</label>
          <div class="controls">
            <input type="text" id="register_nickname" name="nickname" required="required" class="form-control input-lg" data-url="{{path('register_nickname_check')}}" placeholder="该怎么称呼你？ 中、英文均可，最长18个英文或9个汉字">
            <p class="help-block"></p>
          </div>
        </div>
        <div class="form-group mbl">
          <label class="control-label required" for="register_password">密码</label>
          <div class="controls">
            <input type="password" id="register_password" name="password" required="required" class="form-control input-lg" placeholder="5-20位英文、数字、符号，区分大小写">
            <p class="help-block"></p>
          </div>
        </div>

        {% if (setting('auth.captcha_enabled')|default(0)) == 1 and setting('auth.register_mode') != 'mobile' %}
          <div class="form-group mbl js-captcha">
            <label class="control-label required" for="captcha_code">验证码</label>
            <div class="controls row">
              <div class = "col-xs-7">
                <input type="text" class="form-control input-lg" id="captcha_code" name="captcha_code" maxlength="5" placeholder="验证码" required="required"  data-url="{{path('register_captcha_check')}}" >
              </div>
              <div class="col-xs-5">
                <img src="{{ path('register_captcha_num') }}" data-url="{{ path('register_captcha_num') }}" id="getcode_num" title="看不清，点击换一张" style="cursor:pointer;height:40px;width:100%">
              </div>
              <div class="col-md-12 help-block"></div>  
            </div>
          </div>    
        {% endif %}
        
        {% if setting('auth.register_mode') == 'email_or_mobile' or setting('auth.register_mode') == 'mobile' %}
          <div class="form-group mbl {% if setting('auth.register_mode') != 'mobile' %}hidden{% endif %} email_mobile_msg">
            <label class="control-label required" for="sms_code">短信验证码</label>
            <div class="controls row" >
              <div class = "col-xs-7" >
                <input type="text" class="form-control input-lg" id="sms_code" name="sms_code" placeholder="填写你的短信验证码" required="required" data-url="{{path('edu_cloud_sms_check',{type:'sms_registration'})}}">
                <p class="help-block"> </p> 
              </div>
              <div class="col-xs-5">
                <a href="#modal" data-toggle="modal" class="btn btn-default btn-lg js-sms-send disabled" data-url="{{ path('register_captcha_modal') }}" data-sms-url="{{ path('edu_cloud_sms_send') }}">
                  <span id="js-time-left"></span>
                  <span id="js-fetch-btn-text">获取短信验证码</span>
               </a> 
              </div>
            </div>
          </div>
        {% endif %}
        {% if setting('auth.user_terms') == 'opened' %}
          <div class="form-group mbl">
            <div class="controls">
              <label>
                <input type="checkbox" id="user_terms" checked="checked"> 我已阅读并同意<a href="{{ path('user_terms') }}" target="_blank">《服务协议》</a>
              </label>
            </div>
          </div>
        {% endif %}

        <div class="form-group mbl">
          <div class="controls">
            <button type="submit" id="register-btn" data-submiting-text="正在提交" class="btn btn-primary btn-lg btn-block">注册</button>
          </div>
        </div>

        <input type="hidden" name="captcha_enabled" value="{{ setting('auth.captcha_enabled') }}" />
        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

      </form>

      {% if setting('login_bind.enabled') %}
        <div class="social-login">
          <span>
            {{ render(controller('TopxiaWebBundle:Login:oauth2LoginsBlock', {targetPath:_target_path})) }}
          </span>
          <div class="line"></div>
        </div>
      {% endif %}     
    {% else %}
      <div class="empty">系统暂时关闭注册，请联系管理员</div>
    {% endif %}
  </div>
</div>
  {% if setting('login_bind.weixinmob_enabled') == '1' %}
    {% do load_script('auth/isWeiXin') %}
  {% endif %}

{% endblock %}